package com.bocom.service;

import com.bocom.entity.Users;
import com.bocom.dao.UsersDao;

//@Service
//@Transactional
public class UserService {
	
//	@Resource
    private UsersDao userDao;
        
	public UsersDao getUserDao() {
		return userDao;
	}

	public void setUserDao(UsersDao userDao) {
		this.userDao = userDao;
	}
	
	public Users doLogin(String username, String passwrod) throws Exception {
		
		if (username == null || "".equals(username)) {
			throw new Exception("用户名不能为空");
		}
		if (passwrod == null || "".equals(passwrod)) {
			throw new Exception("密码不能为空");
		}		
		Users user = userDao.selectByUsername(username);
		if (user == null) {
			throw new Exception("用户名不存在");
		}
		
		if (!user.getPassword().equals(passwrod)) {
			throw new Exception("密码错误");
		}
		
//		System.out.println("UserService username="+username);
//		System.out.println("UserService passwrod="+passwrod);
		
		return user ;
		
	}
	
}
